<?php

include_once "../../Modele/connexion_bdd.php";
include "head_back_office.php";
include "header_back_office.php";
include "menus_back_office.php";  
include "extras_back_office.php";
include "footer_back_office.php";



//-------------------------GESTION DES ORGANISATEURS----------------------------

function afficherOrganisateur() {
    global $bdd;
    $req = $bdd->prepare('SELECT * FROM organisateur');
    $req->execute();
    $result = $req->fetchall();
    return $result;
}

function nouvelOrganisateur($nomEntreprise, $pseudo, $mdp, $description, $mail, $tel, $activite, $id_localisation) {
    global $bdd;
    $req = $bdd->prepare('INSERT INTO organisateur(nomEntreprise, pseudo, mdp, description, mail, tel, activite, id_localisation) 
                          VALUES (:nomEntreprise, :pseudo, :mdp, :description, :mail, :tel, :activite, :id_localisation)');
    
    $req->bindParam(':nomEntreprise', $nomEntreprise, PDO::PARAM_INT);
    $req->bindParam(':pseudo', $pseudo, PDO::PARAM_INT);
    $req->bindParam(':mdp', $mdp, PDO::PARAM_INT);
    $req->bindParam(':description', $description, PDO::PARAM_INT);
    $req->bindParam(':mail', $mail, PDO::PARAM_INT);
    $req->bindParam(':tel', $tel, PDO::PARAM_INT);
    $req->bindParam(':activite', $activite, PDO::PARAM_INT);
    $req->bindParam(':id_localisation', $id_localisation, PDO::PARAM_INT);
    $req->execute();

}

function supprimerOrganisateur($id) {
    global $bdd;
    $req = $bdd->prepare('DELETE FROM organisateur 
                          WHERE (id = :id)');

    $req->bindParam(':id', $id, PDO::PARAM_INT);
    $req->execute();

}

//-------------------------GESTION DES ORGANISATEURS----------------------------

function afficherUtilisateur() {
    global $bdd;
    $req = $bdd->prepare('SELECT * FROM utilisateur');
    $req->execute();
    $result = $req->fetchall();
    return $result;
}

function nouvelUtilisateur($pseudo, $mdp, $mail, $civilite, $nom, $prenom, $tel) {
    global $bdd;
    $req = $bdd->prepare('INSERT INTO utilisateur(pseudo, mdp, mail, civilite, nom, prenom, tel) 
                          VALUES (:pseudo, :mdp, :mail, :civilite, :nom, :prenom, :tel)');
    
    $req->bindParam(':pseudo', $pseudo, PDO::PARAM_INT);
    $req->bindParam(':mdp', $mdp, PDO::PARAM_INT);
    $req->bindParam(':mail', $mail, PDO::PARAM_INT);
    $req->bindParam(':civilite', $civilite, PDO::PARAM_INT);
    $req->bindParam(':nom', $nom, PDO::PARAM_INT);
    $req->bindParam(':prenom', $prenom, PDO::PARAM_INT);
    $req->bindParam(':tel', $tel, PDO::PARAM_INT);
    $req->execute();

}

function supprimerUtilisateur($id) {
    global $bdd;
    $req = $bdd->prepare('DELETE FROM utilisateur 
                          WHERE (id = :id)');

    $req->bindParam(':id', $id, PDO::PARAM_INT);
    $req->execute();

}

//-------------------------GESTION DES CATEGORIES-------------------------------

function afficherCategorie() {
    global $bdd;
    $req = $bdd->prepare('SELECT * FROM categorie');
    $req->execute();
    $result = $req->fetchall();
    return $result;
}

function nouvelleCategorie($nom, $attribut) {
    global $bdd;
    $req = $bdd->prepare('INSERT INTO categorie(nom, attribut) 
                          VALUES (:nom, :attribut)');
    
    $req->bindParam(':nom', $nom, PDO::PARAM_INT);
    $req->bindParam(':attribut', $attribut, PDO::PARAM_INT);
    $req->execute();

}

function supprimerCategorie($id) {
    global $bdd;
    $req = $bdd->prepare('DELETE FROM categorie 
                          WHERE (id = :id)');

    $req->bindParam(':id', $id, PDO::PARAM_INT);
    $req->execute();

}

//-------------------------GESTION DES COMMENTAIRES----------------------------

function afficherCommentaire() {
    global $bdd;
    $req = $bdd->prepare('SELECT * FROM notecommentaire');
    $req->execute();
    $result = $req->fetchall();
    return $result;
}

function supprimerCommentaire($id) {
    global $bdd;
    $req = $bdd->prepare('DELETE FROM notecommentaire 
                          WHERE (id = :id)');

    $req->bindParam(':id', $id, PDO::PARAM_INT);
    $req->execute();

}

?>
